<template>
<h2>会员权益添加</h2>
    <table border="1">
        <tr>
            <td>权益名称</td>
            <td><input type="text" placeholder="请输入权益名称" v-model="info.MR_Name"/></td>
        </tr>
        <tr>
            <td>权益说明</td>
            <td><input type="text" placeholder="请输入权益说明" v-model="info.MR_Info"/></td>
        </tr>
        <tr>
            <td>是否自定义权益</td>
            <td>
                <input type="radio" :value="true" v-model="info.MR_IdCustom"/>是
                <input type="radio" :value="false" v-model="info.MR_IdCustom"/>否
            </td>
        </tr>
        <tr>
            <td>权益使用规则</td>
            <td><input type="text" placeholder="请输入权益使用规则" v-model="info.MR_Rule"/></td>
        </tr>
        <tr>
            <td>权益类型</td>
            <td>
                <select v-model="info.MR_RuleType">
                    <option :value="0">餐饮</option>
                    <option :value="1">折扣</option>
                    <option :value="2">延时</option>
                </select>
            </td>
        </tr>
        <tr>
            <td><input type="button" value="添加" @click="Add" /></td>
        </tr>
    </table>
</template>
<script setup lang="ts">

    import {ref,onMounted} from 'vue';

    import axios from 'axios';

    const info=ref({
        MR_Name:"",
        MR_Info:"",
        MR_IdCustom: true,
        MR_Rule:"",
        MR_RuleType: 0
    });

    const Add=()=>{
        axios.post("https://localhost:7153/api/Member/AddMemberRights/AddMemberRights",info.value)
        .then(res=>{
            console.log(res.data);
            if(res.data==-1){
                alert('此权益已存在');
            }
            else if(res.data>0){
                alert('添加成功');
            }
            else{
                alert('添加失败');
            }
        })
        .catch(err=>{
            console.log(err);
        })
    }

</script>
